  // JavaScript Document
    
    var submitUsernameOK=false;
    var submitPasswordOK=false;
    var bXmlHttpSupport = (typeof XMLHttpRequest != "undefined" || window.ActiveXObject);
     
    if (typeof XMLHttpRequest == "undefined" && window.ActiveXObject) {
        function XMLHttpRequest() {
            var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
                                 "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                                 "Microsoft.XMLHTTP"];
                             
            for (var i=0; i <  arrSignatures.length; i++) {
                try {        
                    var oRequest = new ActiveXObject(arrSignatures[i]);            
                    return oRequest;        
                } catch (oError) { /*ignore*/ }
            }          
    
            throw new Error("MSXML is not installed on your system.");               
        }
    }    
    //      
    function usernameIsExit() {        
        if(bXmlHttpSupport) {
        	var username=document.getElementById('username').value;
			var sUrl="./usernameIsExit.action?username="+escape(username);
            //var sUrl = 'JsonPlugin.action';
            var oRequest = new XMLHttpRequest();
            oRequest.onreadystatechange = function() {
                if(oRequest.readyState == 4) {                    
                    var useraction = eval('(' + oRequest.responseText + ')');
                    var tips = document.getElementById('usernameTips');
					if(useraction.tipsmessage=="username can use."){
						submitUsernameOK=true;// can submit
						//alert("submitUsernameOK="+submitUsernameOK);
                    	tips.style.color="#339900";
                    }
					else
						tips.style.color="#FF0000";
					 tips.innerHTML = useraction.tipsmessage;
                }
            };
            oRequest.open('POST', sUrl);
            oRequest.send(null);
        }
    }
    function checkpassword(){
		if(registerform.password.value!=registerform.repassword.value){
			document.getElementById("Tipspassword").innerHTML="input wrong!";
			document.getElementById("Tipspassword").style.color="#FF0000";
		}
		else{  //mi ma bu tong yang!
			document.getElementById("Tipspassword").innerHTML="input right.";
			document.getElementById("Tipspassword").style.color="#339900";
			submitPasswordOK=true;
			
		}
	}
	//
	function check_username(){
		//check username
		if(registerform.username.value!=""){
			usernameIsExit();
		}else{
			document.getElementById('usernameTips').innerHTML="username is requre!";
			document.getElementById('usernameTips').style.color="#FF0000";
		}
	}
	function check_password(){
		//check password
		if(registerform.password.value!=""){
			checkpassword();
		}else{
			document.getElementById('repasswordTips').innerHTML="password is requre!";
			document.getElementById('repasswordTips').style.color="#FF0000";
		}
		
	}
	function register_check(){
		if(submitUsernameOK==false || submitPasswordOK==false){
			alert("You have input error!");
			return false;
		}
		if(registerform.username.value==""){
			alert("name is null!");
			return false;
		}
		if(registerform.password.value==""){
			alert("password is null!");
			return false;
		}
		
		registerform.submit();
	}
/*
	window.onload = function(){ 
		var els = document.getElementsByTagName("input"); 
		for(var i=0,n=els.length;i<n;i++){ 
			if(els[i].onfocus){
				//els[i].onfocus = function(){ 
				this.style.background="#FFFFFF"; 
			}
			else{
				//els[i].onblur = function(){ 
				this.style.background="#FFFF99"; 
			}
		}  
	} 

*/
/*
function usernameIsExit()
		{
			var username=document.getElementById('username').value;
			var url="./usernameIsExit.action?username="+escape(username);
			if(window.XMLHttpRequest)
			{
				req=new XMLHttpRequest();
			}
			else if(window.ActiveXObject)
			{
				req=new ActiveXObject("Microsoft.XMLHTTP");
			}
			if(req)
			{
				req.open("GET",url,true);
				req.onreadystatechange=callback;
				req.send(null);
			}
		}
		
function callback()
		{
			//alert(req.readyState);
			if(req.readyState==4)
			{
				if(req.status==200)
				{
					parseMessage();			
				}
				else
				{
					alert("Not found"+req.statusText);
				}
			}
			else
			{
				document.getElementById("usernameTips").innerHTML="checking username...";
			}
		}
		
function parseMessage()
		{
			var xmldoc=req.responseXML.documentElement;
			alert("xmldoc"+xmldoc);
			//var node=xmldoc.getElementsByTagName("info");
			var message=Tipsmessage;
			//document.getElementById("usernameTips").innerHTML=node[0].firstChild.nodeValue;
			document.getElementById("usernameTips").innerHTML=message;
			
			var oBook = eval('(' + oRequest.responseText + ')');
            var bookHolder = document.getElementById('usernameTips');
            var sBook = 'Tipsmessage: ' + oBook.Tipsmessage;
                                    
            bookHolder.innerHTML = sBook;
		}
		
*************		
function check_submit()
		{
			if(login_form.username.value=="")
			{
				document.getElementById("usernameTips").innerHTML="Username required...";
				return false;
			}
			if(login_form.password.value=="")
			{
				document.getElementById("pass").innerHTML="Password required...";
				return false;
			}
			login_form.submit();
		}
*************/